package cn.afei.cloud.controller;

import cn.afei.cloud.config.redis.CacheUtils;
import cn.afei.cloud.entities.Order;
import cn.afei.cloud.feign.CloudCmsFeignService;
import cn.afei.cloud.resp.ResultData;
import cn.afei.cloud.serivce.OrderService;
import cn.afei.cloud.utils.result.ResultVOUtils;
import cn.afei.cloud.utils.result.ResultVo;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @auther zzyy
 * @create 2024-01-06 15:56
 */
@RestController
public class OrderController {

    @Resource
    private OrderService orderService;
    @Resource
    private CloudCmsFeignService cloudCmsFeignService;

    @GetMapping("selectPage")
    public ResultVo selectPage(HttpServletRequest request) {

        CacheUtils.set("c","12342432");
        System.out.println("==============================>:" + CacheUtils.get("c"));
        return orderService.selectListPage();
    }

    @GetMapping("testa")
    public String testa(HttpServletRequest request) {

        String aaa = "app->testa";
        return aaa;
    }

    @GetMapping("testb")
    public ResultVo testb(HttpServletRequest request) {
        String testa = cloudCmsFeignService.testa();
        String dddd = "app->testa" + "--------------" + testa;
        return ResultVOUtils.success(dddd);
    }


    /**
     * 创建订单
     */
    @GetMapping("/order/create")
    public ResultData create(Order order) {
        orderService.create(order);
        return ResultData.success(order);
    }
}
